<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Insert title here</title>
		<!-- 引入样式 -->
		<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
		<script src="../js/vue.js"></script>
		<!-- 引入组件库 -->
		<script src="https://unpkg.com/element-ui/lib/index.js"></script>
		<!-- 引入axios -->
		<script src="../js/axios.js"></script>
		<script src="../js/qs.js"></script>
		<!-- 导入jquery -->
		<script src="../js/jquery.min.js"></script>
		<style type="text/css">
			.custom-tree-node {
				flex: 1;
				display: flex;
				align-items: center;
				justify-content: space-between;
				font-size: 14px;
				padding-right: 8px;
			}
		</style>
	</head>
	<body>
		<div style="margin-left: 15px;" id="app">
			<el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal">
				<el-menu-item index="1">用户管理</el-menu-item>
			</el-menu>
		</div>
		<div style="margin-left: 15px; margin-top:10px ;" id="app1">
			<el-row>
				<el-col :span="6">
					<div id="" style="width: 90%;">
						<div id="" style=" height: 40px;  background-color: #F2F2F2; line-height: 40px;padding-left: 5px; border-bottom :1px solid #E6E6E6">
							部门列表
							<i style="margin-left: 5px; font-size: 14px; cursor: pointer;" @click="addDept()" class="el-icon-circle-plus"></i>
							<!-- 添加部门 -->
							<el-dialog title="添加部门" width="30%" :visible.sync="addDeptdialog">
								<hr style="border: 0.5px solid #666666;margin: -15px 0px 35px;" />
								<el-form :rules="rules" ref="addDeptfroms" :model="addDeptfroms">
									<el-row :gutter="10">
										<el-form-item label="上级部门:" required prop="parentid" :label-width="formLabelWidth">
											<el-select v-model="addDeptfroms.parentid" @clear="clearAllDept()" clearable filterable="" style="width: 80%;"
											 remote="" reserve-keyword placeholder="请输入关键词" :remote-method="deptmoteMethod" :loading="deptloading">
												<i slot="prefix" class="el-input__icon el-icon-search"></i>
												<el-option v-for="item in findDept" :key="item.value" :label="item.label" :value="item.value">
												</el-option>
											</el-select>
										</el-form-item>
									</el-row>
									<el-row :gutter="10">
										<el-form-item label="名称:" required prop="deptName" :label-width="formLabelWidth">
											<el-input v-model="addDeptfroms.deptName" style="width: 80%;" placeholder="请输入内容"></el-input>

										</el-form-item>
									</el-row>
									<el-row :gutter="10">
										<el-form-item label="顺序:" required prop="deptSeq" :label-width="formLabelWidth">
											<el-input v-model="addDeptfroms.deptSeq" style="width: 80%;" placeholder="请输入内容"></el-input>
										</el-form-item>
									</el-row>
									<el-row :gutter="10">
										<el-form-item label="备注:" :label-width="formLabelWidth">
											<el-input type="textarea" :rows="12" :autosize="{ minRows: 3}" placeholder="" v-model="addDeptfroms.textcommunication"
											 style="width: 80%;"></el-input>
										</el-form-item>
									</el-row>
								</el-form>
								<div slot="footer" class="dialog-footer">
									<el-button @click="dialogFormVisible = false">取 消</el-button>
									<!-- dialogFormVisible = false -->
									<el-button type="primary" @click="submitdeptForm('addDeptfroms')">保存</el-button>
								</div>
							</el-dialog>
							<!-- 修改部门 -->
							<el-dialog title="修改部门" width="30%" :visible.sync="updateDeptdialog">
								<hr style="border: 0.5px solid #666666;margin: -15px 0px 35px;" />
								<el-form :rules="rules" ref="updateDeptfroms" :model="updateDeptfroms">
									<el-row :gutter="10">
										<el-form-item label="上级部门:" required prop="parentid" :label-width="formLabelWidth">
											<el-select v-model="updateDeptfroms.parentid" @clear="clearAllDept()" clearable filterable="" style="width: 80%;"
											 remote="" reserve-keyword placeholder="请输入关键词" :remote-method="deptmoteMethod" :loading="deptloading">
												<i slot="prefix" class="el-input__icon el-icon-search"></i>
												<el-option v-for="item in findDept" :key="item.value" :label="item.label" :value="item.value">
												</el-option>
											</el-select>
										</el-form-item>
									</el-row>
									<el-row :gutter="10">
										<el-form-item label="名称:" required prop="deptName" :label-width="formLabelWidth">
											<el-input v-model="updateDeptfroms.deptName" style="width: 80%;" placeholder="请输入内容"></el-input>

										</el-form-item>
									</el-row>
									<el-row :gutter="10">
										<el-form-item label="顺序:" required prop="deptSeq" :label-width="formLabelWidth">
											<el-input v-model="updateDeptfroms.deptSeq" style="width: 80%;" placeholder="请输入内容"></el-input>
										</el-form-item>
									</el-row>
									<el-row :gutter="10">
										<el-form-item label="备注:" required :label-width="formLabelWidth">
											<el-input type="textarea" :rows="12" :autosize="{ minRows: 3}" placeholder="" v-model="updateDeptfroms.textcommunication"
											 style="width: 80%;"></el-input>
										</el-form-item>
									</el-row>
								</el-form>
								<div slot="footer" class="dialog-footer">
									<el-button @click="dialogFormVisible = false">取 消</el-button>
									<!-- dialogFormVisible = false -->
									<el-button type="primary" @click="submitupdatedeptForm('updateDeptfroms')">保存</el-button>
								</div>
							</el-dialog>

						</div>
						<el-tree :data="data1" node-key="id" default-expand-all :expand-on-click-node="false">
							<span class="custom-tree-node" slot-scope="{ node, data }">
								<span @click="clickDept(data.id)">{{ node.label }}</span>
								<span style="float: right; margin-right:0%">
									<i class="el-icon-edit" @click="updateDept(data.id)" style="font-size: 15px;"></i>
									<i class="el-icon-delete" style="margin: 0px 2px;font-size: 15px;" @click="deleteDept(data.id)"></i>
								</span>
							</span>
						</el-tree>
					</div>
				</el-col>
				<el-col :span="18">
					<div id="" style=" height: 40px;  width: 98%; background-color: #F2F2F2; line-height: 40px;padding-left: 5px; border-bottom :1px solid #E6E6E6">
						用户列表
						<span style=""><i style="margin-left: 5px; font-size: 14px; cursor: pointer;" @click="addUser()" class="el-icon-circle-plus"></i>
						<!-- 搜索框 -->
						<div style="display: block;margin-left: -20px;float: right; cursor: pointer;">
							<el-input style="width: 200px; height: 20px;" placeholder=""  v-model="inputtheme">
								<el-button slot="append" @click="search()"  style=" width: 80px;">
									姓名
								</el-button>
							</el-input>
						</div>
							<el-dialog title="添加用户" width="40%" :visible.sync="addUserdialog">
							<hr style="border: 0.5px solid #666666;margin: -15px 0px 35px;" />
							<el-form :rules="rules" ref="addUserfroms" :model="addUserfroms">
								<el-row :gutter="10">
									<el-form-item label="上级部门:" required prop="parentid" :label-width="formLabelWidth">
										<el-select v-model="addUserfroms.parentid" @clear="clearAllDept()" clearable filterable="" style="width: 80%;"
										 remote="" reserve-keyword placeholder="请输入关键词" :remote-method="deptmoteMethod" :loading="deptloading">
											<i slot="prefix" class="el-input__icon el-icon-search"></i>
											<el-option v-for="item in findDept" :key="item.value" :label="item.label" :value="item.value">
											</el-option>
										</el-select>
									</el-form-item>
								</el-row> 
								<el-row :gutter="10">
									<el-form-item label="用户名:" required prop="uName" :label-width="formLabelWidth">
										<el-input v-model="addUserfroms.uName" style="width: 80%;" placeholder="请输入内容"></el-input>
									</el-form-item>
								</el-row>
								<el-row :gutter="10">
									<el-form-item label="对应角色:"  :label-width="formLabelWidth">
										<el-select v-model="uRoles" multiple placeholder="请选择">
											<el-option
												v-for="item in rolesData"
													:key="item.value"
													:label="item.label"
													:value="item.value">
												</el-option>
											</el-select>
									</el-form-item>
								</el-row>
								<el-row :gutter="10">
									<el-form-item label="性别:" required prop="uSex" :label-width="formLabelWidth">
										<template>
											<el-radio v-model="addUserfroms.uSex" label="1005">男</el-radio>
											<el-radio v-model="addUserfroms.uSex" label="1006">女</el-radio>
										</template>
									</el-form-item>
								</el-row>
								<el-row :gutter="10">
									<el-form-item label="身份证:" prop="uIdcard" :label-width="formLabelWidth">
										<el-input v-model="addUserfroms.uIdcard" style="width: 80%;" placeholder="请输入身份证"></el-input>
									</el-form-item>
								</el-row>
								<el-row :gutter="10">
									<el-form-item label="手机号:" prop="uPhone" :label-width="formLabelWidth">
										<el-input v-model="addUserfroms.uPhone" style="width: 80%;" placeholder="请输入手机号"></el-input>
									</el-form-item>
								</el-row>
								<el-row :gutter="10">
									<el-form-item label="邮箱:" prop="uEmail" :label-width="formLabelWidth">
										<el-input v-model="addUserfroms.uEmail" style="width: 80%;" placeholder="请输入邮箱"></el-input>
									</el-form-item>
								</el-row>
							</el-form>
							<div slot="footer" class="dialog-footer">
								<el-button @click="dialogFormVisible = false">取 消</el-button>
								<!-- dialogFormVisible = false -->
								<el-button type="primary" @click="submitUserForm('addUserfroms')">保存</el-button>
							</div>
						</el-dialog>
						
					</div>
					<div style=" height: 40px;  width: 98.5%;" >
							<el-dialog title="修改用户" width="40%" :visible.sync="updateUserdialog">
							<hr style="border: 0.5px solid #666666;margin: -15px 0px 35px;" />
							<el-form :rules="rules" ref="updateUserfroms" :model="updateUserfroms">
								<el-row :gutter="10">
									<el-form-item label="上级部门:" required prop="parentid" :label-width="formLabelWidth">
										<el-select v-model="updateUserfroms.parentid" @clear="clearAllDept()" clearable filterable="" style="width: 80%;"
										 remote="" reserve-keyword placeholder="请输入关键词" :remote-method="deptmoteMethod" :loading="deptloading">
											<i slot="prefix" class="el-input__icon el-icon-search"></i>
											<el-option v-for="item in findDept" :key="item.value" :label="item.label" :value="item.value">
											</el-option>
										</el-select>
									</el-form-item>
								</el-row> 
								<el-row :gutter="10">
									<el-form-item label="对应角色:"  :label-width="formLabelWidth">
										<el-select v-model="uRoles" multiple placeholder="请选择">
											<el-option
												v-for="item in rolesData"
													:key="item.value"
													:label="item.label"
													:value="item.value">
												</el-option>
											</el-select>
									</el-form-item>
								</el-row>
								<el-row :gutter="10">
									
									<el-form-item label="用户名:" required prop="uName" :label-width="formLabelWidth">
										<el-input v-model="updateUserfroms.uName" style="width: 80%;" placeholder="请输入内容"></el-input>
									</el-form-item>
								</el-row>
								<el-row :gutter="10">
									<el-form-item label="性别:" required prop="uSex" :label-width="formLabelWidth">
										<template>
											<el-radio v-model="updateUserfroms.uSex" :label="1005">男</el-radio>
											<el-radio v-model="updateUserfroms.uSex" :label="1006">女</el-radio>
										</template>
									</el-form-item>
								</el-row>
								<el-row :gutter="10">
									<el-form-item label="身份证:" prop="uIdcard" :label-width="formLabelWidth">
										<el-input v-model="updateUserfroms.uIdcard" style="width: 80%;" placeholder="请输入身份证"></el-input>
									</el-form-item>
								</el-row>
								<el-row :gutter="10">
									<el-form-item label="手机号:" prop="uPhone" :label-width="formLabelWidth">
										<el-input v-model="updateUserfroms.uPhone" style="width: 80%;" placeholder="请输入手机号"></el-input>
									</el-form-item>
								</el-row>
								<el-row :gutter="10">
									<el-form-item label="邮箱:" prop="uEmail" :label-width="formLabelWidth">
										<el-input v-model="updateUserfroms.uEmail" style="width: 80%;" placeholder="请输入邮箱"></el-input>
									</el-form-item>
								</el-row>
							</el-form>
							
							
							<div slot="footer" class="dialog-footer">
								<el-button @click="dialogFormVisible = false">取 消</el-button>
								<!-- dialogFormVisible = false -->
								<el-button type="primary" @click="updateUserForm('updateUserfroms')">保存</el-button>
							</div>
						</el-dialog>
						
						<template>
								<el-table ref="multipleTable" tooltip-effect="dark"   :data="multipleTable" border style="width: 100%;color: black;">
									<el-table-column type="selection" width="35" align="center" >
									</el-table-column>
									<el-table-column prop="uId" label="编号" width="60" align="center">
									</el-table-column>
									<el-table-column prop="uName" label="姓名" align="center">
									</el-table-column>
									<el-table-column prop="deptName" label="所属部门" align="center">
									</el-table-column>
									<el-table-column prop="uPhone" label="电话" align="center">
									</el-table-column>
									<el-table-column fixed="right" label="操作" width="100" align="center">
										<template slot-scope="scope">
												<el-tooltip content="Bottom center" placement="bottom">
												<div slot="content">编辑</div>
												<i class="el-icon-edit" @click="updatehandleClick(scope.row.uId)" style="font-size: 17px;"></i>
											</el-tooltip>
											<el-tooltip content="Bottom center" placement="bottom">
												<div slot="content">删除</div>
												<i class="el-icon-delete" style="margin: 0px 10px;font-size: 17px;" @click="deleteUserShow(scope.row.ID)"></i>
											</el-tooltip>
										
											<el-dialog title="提示" :visible.sync="dialogDelete" width="30%" append-to-body >
								 	 			<span>你确定要删除吗？</span>
									  				<span slot="footer" class="dialog-footer">
									   				<el-button @click="dialogDelete = false">取 消</el-button>
									   				<el-button type="primary" @click="dialogDelete = false" v-on:click="DeleteUser" >确 定</el-button>
								 				</span>
											</el-dialog>
											
										</template>
									</el-table-column>
								</el-table>
								<div style="margin-top: 10px">
									<div style="display: block; float: left;margin-left: 5px;">
										<el-tooltip content="Bottom center" placement="bottom">
											<div slot="content">删除</div>
											<i class="el-icon-delete" style="margin: 8px;font-size: 17px;"></i>
										</el-tooltip>
									</div>
									<!-- 分页 -->
									<div style="display: block; float: left; margin-left: 150px;">
										<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage4"
										 :page-sizes="[4, 6, 8,10]" :page-size="pages.pageSize" layout="total, sizes,prev, pager, next, jumper" :total="pages.total">
										</el-pagination>
									</div>
									<div style="display: block; float: right;margin-right: 5px;">
										<el-tooltip content="Bottom center" placement="bottom">
											<div slot="content">打印</div>
											<el-button circle size="mini"><i class="el-icon-printer" style="font-size: 17px;"></i></el-button>&nbsp;
										</el-tooltip>
							
										<el-tooltip content="Bottom center" placement="bottom">
											<div slot="content">导出Excel</div>
											<el-button circle size="mini"><i class="el-icon-tickets" style="font-size: 17px;"></i></el-button>
										</el-tooltip>
							
									</div>
								</div>
							</template>
						
					</div>
				</el-col>
				</div>
		</el-row>
		</div>
		
		<script type="text/javascript">
			var deptTree = ${
				deptTree
			};
			var pageinfo = ${pagejson};
			var listTable=${list};
			var app = new Vue({
				el: "#app",
				data: {
					activeIndex: '1',
					activeIndex2: '1',
				},
				methods: {

				}
			});
			//手机号验证
			var validateIdChar = (rule, value, callback) => {
				var myreg=/^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/;
				if (!myreg.test(value)) {
					callback(new Error('请输入正确的身份证号'));
				} else {
					callback();
				}
			};
			//手机号验证
			var validatephon = (rule, value, callback) => {
				var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
				if (!myreg.test(value)) {
					callback(new Error('请输入正确的手机号'));
				} else {
					callback();
				}
			};
			//邮箱验证
			var validateem = (rule, value, callback) => {
				var myreg=/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
				if (!myreg.test(value)) {
					callback(new Error('请输入正确的邮箱'));
				} else {
					callback();
				}
			};
			var app1 = new Vue({
				el: "#app1",
				data: {
					formLabelWidth: '90px',
					data1: deptTree,
					uRoles:'',
					addDeptdialog: false,
					addUserdialog:false,
					updateDeptdialog: false,
					updateUserdialog:false,
					inputtheme:'',
					multipleTable:listTable,
					rolesData:'',
					rules: {
						uPhone: [{
							validator: validatephon,
							trigger: 'blur'
						}],
						uEmail:[{
							validator: validateem,
							trigger: 'blur'
						}],
						uIdcard:[{
							validator: validateIdChar,
							trigger: 'blur'
						}],
						parentid: [{
							required: true,
							message: '请选择上级部门',
							trigger: 'change',
							required: true,
							message: '请选择上级部门',
							trigger: 'blur'
						}, ],
						deptName: [{
							required: true,
							message: '请输入部门名字',
							trigger: 'change',
							required: true,
							message: '请输入部门名字',
							trigger: 'blur'
						}, ],
						uName: [{
							required: true,
							message: '请输入用户名',
							trigger: 'change',
							required: true,
							message: '请输入用户名',
							trigger: 'blur'
						}, ],
						deptSeq: [{
							required: true,
							message: '请输入顺序',
							trigger: 'change',
							required: true,
							message: '请输入顺序',
							trigger: 'blur'
						}, ],
						uSex: [{
							required: true,
							message: '请选择性别',
							trigger: 'change',
						}, ],
					},
					addDeptfroms: {
						parentid: '',
						deptName: '',
						deptSeq: '',
						textcommunication: ''
					},
					addUserfroms:{
						parentid: '',
						uName: '',
						uEmail: '',
						uPhone: '',
						uIdcard: '',
						uRole:'',
						uSex: '1005',
					},
					updateDeptfroms: {
						id: '',
						parentid: '',
						deptName: '',
						deptSeq: '',
						textcommunication: '',
					},
					updateUserfroms:{
						uId:'',
						parentid: '',
						uName: '',
						uEmail: '',
						uPhone: '',
						uIdcard: '',
						uSex: '',
						uRole:'',
						
					},
					findDept: [],
					findDepts: [],
					pages: pageinfo,
					currentPage4: pageinfo.pageNum,
					deptloading: false,
					dialogDelete:false,
					deptId:null,
					value7:'',
					
				},
				methods: {
						search(){
						var pageSize= Max.pasSize;
						var statusid=null;
						var search=null;
						var _this=this;
						//判断是否带条件;
						//判断是否根据条件筛选
						if(this.value7.toString()=='2'||this.value7.toString()==''){
							if(this.inputtheme==""){
								window.location.hash='#/authority/users';
							}
							else{
								window.location.hash='#/authority/users?search='+this.inputtheme;
								search=this.inputtheme;
							}
						}else{
							statusid=this.value7.toString();
							if(this.inputtheme==""){
								window.location.hash=window.location.hash.split('&')[0];
							}
							else{
								window.location.hash=window.location.hash.split('&')[0]+'&search='+this.inputtheme;
								search=decodeURI(this.inputtheme);
							}
						}
						$.ajax({
						      type: "post",
						      url: "/authority/users",
						      data: {pageNum:1,pageSize:pageSize,statusid:statusid,search:search,drptId:_this.deptId},
						      success: function (sdata) {
						    	  console.log("页数打印*****："+sdata);
						    	 _this.multipleTable=sdata.list;
						    	 _this.pages=sdata;
						    	 _this.currentPage4=sdata.pageNum;
						      }
						});
					},
					addDept() {
						var _this = this;
						axios.post("/authority/addDeptview",
							//ajax请求成功的回调函数
						).then(function(v) {
							console.log("回调成功，获取了服务器端返回的值v");
							console.log(v.data);
							//将数据装换成界面显示
							//客户信息
							_this.findDepts = v.data.deptAll.map(item => {
								return {
									value: item.id,
									label: item.name
								};
							});
							var a = {
								value: 0,
								label: "最高层级"
							};
							_this.findDepts.push(a);
							_this.findDept = _this.findDepts;
							console.log(_this.findDepts);
							_this.addDeptdialog = true;
						}).catch(function() {
							alert("信息出错了");
						});
					},
					addUser(){
						var _this = this;
						axios.post("/authority/addUserview",
							//ajax请求成功的回调函数
						).then(function(v) {
							console.log("回调成功，获取了服务器端返回的值v");
							console.log(v.data);
							//将数据装换成界面显示
							//客户信息
							//角色数据
							_this.rolesData=JSON.parse( v.data.roleAll);
							_this.findDepts = v.data.deptAll.map(item => {
								return {
									value: item.id,
									label: item.name
								};
							});
							_this.findDept = _this.findDepts;
							console.log(_this.findDepts);
							_this.addUserdialog = true;
						})/* .catch(function() {
							alert("信息出错了");
						});.catch(function() {
							alert("信息出错了");
						}); */
					},
					clickDept(id) {
						//查询的行数
						var pageSize= Max.pasSize;
						var statusid=null;
						var search=null;
						var _this=this;
						//判断是否带条件;
						var url= window.location.href;
						var url1= url.indexOf("?");
						if(url1!=-1){
							//this.complaintheme=decodeURI(url.substring(url1+1,url.length).split('&')[0].split('=')[1]);
							//截取每一个条件
							var urlcondition= url.substring(url1+1,url.length).split('&');
							for(var i=0;i<urlcondition.length;i++){
								
								if(urlcondition[i].split('=')[0]=="statusid"){
									statusid=decodeURI(urlcondition[i].split('=')[1]);
								}
								if(urlcondition[i].split('=')[0]=="search"){
									search=decodeURI(urlcondition[i].split('=')[1]);
								}
							}
						}
						$.ajax({
						      type: "post",
						      url: "/authority/users",
						      data: {pageNum:1,pageSize:pageSize,statusid:statusid,search:search,drptId:id},
						      success: function (sdata) {
						    	  console.log("页数打印*****："+sdata);
						    	  _this.multipleTable=sdata.list;
						          _this.pages=sdata;
								  _this.currentPage4=sdata.pageNum;
								  _this.deptId=id;
						      }
						});
					},
					updateDept(id) {
						var _this = this;
						axios.post("/authority/updateDeptview",
							Qs.stringify({
								'ID': id,
							}, {
								arrayFormat: 'brackets'
							})
							//ajax请求成功的回调函数
						).then(function(v) {
							console.log("回调成功，获取了服务器端返回的值v");
							console.log(v.data);
							//将数据装换成界面显示
							//客户信息
							_this.findDepts = v.data.deptAll.map(item => {
								return {
									value: item.id,
									label: item.name
								};
							});
							var a = {
								value: 0,
								label: "最高层级"
							};
							_this.findDepts.push(a);
							_this.findDept = _this.findDepts;
							_this.updateDeptfroms.id = v.data.sysDept.id;
							_this.updateDeptfroms.parentid = v.data.sysDept.parentid;
							_this.updateDeptfroms.deptName = v.data.sysDept.name;
							_this.updateDeptfroms.deptSeq = v.data.sysDept.seq;
							_this.updateDeptfroms.textcommunication = v.data.sysDept.remark;
							_this.updateDeptdialog = true;
						}).catch(function() {
							alert("信息出错了");
						});
					},
					//修改用户
					updatehandleClick(id) {
						var _this = this;
						axios.post("/authority/updateUserview",
							Qs.stringify({
								'ID': id,
							}, {
								arrayFormat: 'brackets'
							})
							//ajax请求成功的回调函数
						).then(function(v) {
							console.log("回调成功，获取了服务器端返回的值v");
							console.log(v.data);
							_this.rolesData=JSON.parse(v.data.roleAll);
							//将数据装换成界面显示
							//客户信息
							//将数据装换成界面显示
							//客户信息
							_this.findDepts = v.data.deptAll.map(item => {
								return {
									value: item.id,
									label: item.name
								};
							});
							_this.findDept = _this.findDepts;
							_this.updateUserfroms.uId = v.data.user.uId;
							_this.updateUserfroms.parentid = v.data.user.uDept;
							_this.updateUserfroms.uName = v.data.user.uName;
							_this.updateUserfroms.uEmail = v.data.user.uEmail;
							_this.updateUserfroms.uPhone = v.data.user.uPhone;
							_this.updateUserfroms.uIdcard = v.data.user.uIdcard;
							_this.updateUserfroms.uSex = v.data.user.uSex;
							
							  _this.uRoles= JSON.parse(v.data.roletoUser);
							 
							_this.updateUserdialog = true;
						})/* .catch(function() {
							alert("信息出错了");
						}); */
					},
					handleSizeChange(val) {
						Max.pasSize=val;
						var statusid=null;
						var search=null;
						var _this=this;
						//判断是否带条件;
						var url= window.location.href;
						var url1= url.indexOf("?");
						if(url1!=-1){
							//截取每一个条件
							var urlcondition= url.substring(url1+1,url.length).split('&');
							for(var i=0;i<urlcondition.length;i++){
								
								if(urlcondition[i].split('=')[0]=="statusid"){
									statusid=decodeURI(urlcondition[i].split('=')[1]);
								}
								if(urlcondition[i].split('=')[0]=="search"){
									search=decodeURI(urlcondition[i].split('=')[1]);
								}
							}
						}
						$.ajax({
						      type: "post",
						      url: "/authority/users",
						      data: {pageNum:1,pageSize:val,statusid:statusid,search:search,drptId:_this.deptId},
						      success: function (sdata) {
						    	  console.log("页数打印*****："+sdata);
						    	  _this.multipleTable=sdata.list;
						    	  _this.pages=sdata;
						    	  _this.currentPage4=sdata.pageNum;
						      }
						});
					},
					handleCurrentChange(val) {
						//查询的行数
						var pageSize= Max.pasSize;
						var statusid=null;
						var search=null;
						var _this=this;
						//判断是否带条件;
						var url= window.location.href;
						var url1= url.indexOf("?");
						if(url1!=-1){
							//this.complaintheme=decodeURI(url.substring(url1+1,url.length).split('&')[0].split('=')[1]);
							//截取每一个条件
							var urlcondition= url.substring(url1+1,url.length).split('&');
							for(var i=0;i<urlcondition.length;i++){
								
								if(urlcondition[i].split('=')[0]=="statusid"){
									statusid=decodeURI(urlcondition[i].split('=')[1]);
								}
								if(urlcondition[i].split('=')[0]=="search"){
									search=decodeURI(urlcondition[i].split('=')[1]);
								}
							}
						}
						$.ajax({
						      type: "post",
						      url: "/authority/users",
						      data: {pageNum:val,pageSize:pageSize,statusid:statusid,search:search,drptId:_this.deptId},
						      success: function (sdata) {
						    	  console.log("页数打印*****："+sdata);
						    	   _this.multipleTable=sdata.list;
						    	  _this.pages=sdata;
						    	  _this.currentPage4=sdata.pageNum;
						      }
						});
					},
					deleteDept(id) {
						alert(id);
					},
					//加载界面部门
					deptmoteMethod(query) {
						var _this = this;
						if (query !== '') {
							this.deptloading = true;
							setTimeout(() => {
								this.deptloading = false;
								this.findDept = _this.findDepts.filter(item => {
									return item.label.toLowerCase()
										.indexOf(query.toLowerCase()) > -1;
								});
							}, 200);
						} else {
							this.findDept = this.findDepts;
						}
					},
					clearAllDept() {
						this.findDept = this.findDepts;
					},
					//添加部门
					submitdeptForm(addDeptfroms) {
						var _this = this;
						this.$refs[addDeptfroms].validate((valid) => {
							if (valid) {
								//post提交数据
								axios.post("/authority/addDept",
									//参数转换
									Qs.stringify(
										this.addDeptfroms, {
											arrayFormat: 'brackets'
										})
									//	params:
									//ajax请求成功的回调函数
								).then(function(v) {
									console.log("回调成功，获取了服务器端返回的值v");
									console.log(v);
									_this.addDeptdialog = false;
									showAtRight('/authority/users');
								}).catch(function() {
									alert("出错了");
								}); 
							} else {
								console.log('error submit!!');
								return false;
							}
						});
					},
					submitupdatedeptForm(addDeptfroms) {
						var _this = this;
						this.$refs[addDeptfroms].validate((valid) => {
							if (valid) {
								//post提交数据
								axios.post("/authority/updateDept",
									//参数转换
									Qs.stringify(
									this.updateDeptfroms
									,{arrayFormat: 'brackets'})
									//	params:
									//ajax请求成功的回调函数
									).then(function(v){
									console.log("回调成功，获取了服务器端返回的值v");
									console.log(v);
									_this.updateDeptdialog = false;
									showAtRight('/authority/users');
							}).catch(function(){
								alert("出错了");
							});
							} else {
								console.log('error submit!!');
								return false;
							} 
						});
					},
					//添加用户
					submitUserForm(addDeptfroms) {
						this.addUserfroms.uRole=JSON.stringify(this.uRoles);
						var _this = this;
						this.$refs[addDeptfroms].validate((valid) => {
							if (valid) {
								//post提交数据
								axios.post("/authority/addUser",
									//参数转换
									Qs.stringify(
									this.addUserfroms
									,{arrayFormat: 'brackets'})
									//	params:
									//ajax请求成功的回调函数
									).then(function(v){
									console.log("回调成功，获取了服务器端返回的值v");
									console.log(v);
									_this.addUserdialog = false;
									showAtRight('/authority/users');
							}) .catch(function(){
								alert("出错了");
							}); 
							} else {
								console.log('error submit!!');
								return false;
							} 
						});
					},
					updateUserForm(addDeptfroms) {
						this.updateUserfroms.uRole=JSON.stringify(this.uRoles);
						var _this = this;
						this.$refs[addDeptfroms].validate((valid) => {
							if (valid) {
								//post提交数据
								axios.post("/authority/updateUser",
									//参数转换
									Qs.stringify(
									this.updateUserfroms
									,{arrayFormat: 'brackets'})
									//	params:
									//ajax请求成功的回调函数
									).then(function(v){
									console.log("回调成功，获取了服务器端返回的值v");
									console.log(v);
									_this.updateUserdialog = false;
									showAtRight('/authority/users');
							}) .catch(function(){
								alert("出错了");
							}); 
							} else {
								console.log('error submit!!');
								return false;
							} 
						});
					},
					//删除用户接口
					DeleteUser(){
						var _this=this;
						axios.post("/sales/prosale/deletetrm",
					   			//参数转换
					   			Qs.stringify({
									'ID':_this.ID
								},{arrayFormat: 'brackets'})
					   			//ajax请求成功的回调函数
					  			).then(function(response){					          				
					   			console.log("回调成功，获取了服务器端返回的值v");
					   			console.log(response.data);					           		
					   		/* this.$message({
								type: 'success',
								message: '删除成功!'
							}); */
					   		alert("删除成功！");
					   		window.location.href = '/sales/prosale/returnMoney';
												
					   	}) 
						.catch(function(){
					   		alert("删除失败！");
					   		/*this.$message({
								type: 'error',
								message: '删除失败!'*/
							});
						//这个是数据的初始化
					  },
					  deleteUserShow(ID){
					  	this.ID=ID;
					  	this.dialogDelete=true;
					  	
					  },

				}
				
			});
		</script>
	</body>
</html>
